package com.by.controller;

import cn.hutool.core.bean.BeanUtil;
import com.by.bean.FreightEnquiry;
import com.by.common.bean.PageBean;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.query.FreightCleintQuery;
import com.by.query.FreightQuery;
import com.by.service.FreightEnquiryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "货代询价")
@RequestMapping("/v1")
public class FreightController extends BaseController {

    @Autowired
    FreightEnquiryService freightEnquiryService;

    @ApiOperation("保存询价")
    @PostMapping("/freightEnquiry")
    public ResultBean save(@RequestBody FreightEnquiry freightEnquiry){
        int rs=freightEnquiryService.save(freightEnquiry);
        return saveResult(rs);
    }


    @ApiOperation("货代管理")
    @PostMapping("/freightEnquiry/query")
    public ResultBean query(@RequestBody FreightQuery query){
        PageBean bean=freightEnquiryService.query(BeanUtil.beanToMap(query));
        return success("货代列表",bean);
    }

    @ApiOperation("货代列表")
    @PostMapping("/freightEnquiry/list")
    public ResultBean queryFreight(@RequestBody FreightCleintQuery query){
        PageBean bean=freightEnquiryService.queryFreight(query);
        return success("货代列表",bean);
    }

}
